<?php
ob_start();
session_start();

include("conf/config.php");
include("conf/database.php");
include("conf/tools.php");
$memberId=$_SESSION["member_id"];
$curTime=getIndianDateTime();
$mem_old=getMemberInfo($memberId);
foreach($_POST as $key => $value) { $arr_data[$key]=$value;}

$arr_data["gender"]=$arr_data["rbGender"];
if($arr_data["reg_state"]=="Other") $arr_data["reg_state"]=$arr_data["reg_state_other"];
$arr_data["telephone_no"]=$arr_data["telephone_number"];
$arr_data["alternate_email_id"]=$arr_data["alternate_email"];
$arr_data["email_id"]=$arr_data["email_address"];


if($arr_data["reg_state"]=="Other") $arr_data["reg_state"]=$_POST["reg_country_other"];
if($arr_data["reg_country"]=="Other") $arr_data["reg_country"]=$_POST["reg_country_other"];
if($arr_data["reg_state1"]=="Other") $arr_data["reg_state1"]=$_POST["reg_country_other1"];
if($arr_data["reg_country1"]=="Other") $arr_data["reg_country1"]=$_POST["reg_country_other1"];

if($arr_data["edu_qual"]=="Other") $arr_data["edu_qual"]=$_POST["edu_qual_other"];
if($arr_data["technical_specifications"]=="Other") $arr_data["technical_specifications"]=$_POST["technical_specifications_other"];

$_SESSION["is_bk"]=$arr_data["are_you_bk"];
foreach($arr_data as $key => $value) { $arr_data[$key]=addslashes($value); }


update_qry("bkitc_profiles",$arr_data,"registrant_id=".$memberId);

qry_data("update bkitc_profiles set last_updated='".$curTime."' where registrant_id=".$memberId);

$mem_new=getMemberInfo($memberId);
$arr_log=Array("old"=>$mem_old,"new"=>$mem_new);
$log_content=serialize($arr_log);
writeLog($mem_new["full_name"]." changed profile" ,$log_content,0,1);



$target_path = "images/photos/";
$target_path1 = "data/resumes/";

$actual_path=$target_path . $memberId . "/";
if(!is_dir($target_path)) mkdir($target_path);
if(!is_dir($actual_path)) mkdir($actual_path);


$actual_path1=$target_path1 . $memberId . "/";
if(!is_dir($target_path1)) mkdir($target_path1);
if(!is_dir($actual_path1)) mkdir($actual_path1);


$target_path = $target_path . basename( $_FILES['file_photo']['name']); 
$target_path1 = $target_path1 . basename( $_FILES['file_resume']['name']); 

$arrInfo=array();
if(move_uploaded_file($_FILES['file_photo']['tmp_name'],$actual_path.$_FILES['file_photo']['name'])) {

	$arrInfo["photo_filename"]=$_FILES['file_photo']['name'];
	
	update_qry("bkitc_profiles",$arrInfo," registrant_id=".$memberId);

} 
$arrInfo=array();
if(move_uploaded_file($_FILES['file_resume']['tmp_name'],$actual_path1.$_FILES['file_resume']['name'])) {

	$arrInfo["resume_filename"]=$_FILES['file_resume']['name'];
	$arrInfo["resume_uploaded"]=$curTime;
	
	update_qry("bkitc_profiles",$arrInfo," registrant_id=".$memberId);

} 



header("location:profile.php?mode=1");

?>

